package org.cloud.im.core.ws;

import org.tio.utils.hutool.Snowflake;

import java.util.concurrent.ThreadLocalRandom;

/**
 * @Author: w.weidong.lin@abite.com
 * @Description: TODO
 * @Date: create in 2021/10/19 14:39
 */
public class WsUuid {
    private Snowflake snowflake;

    public WsUuid() {
        snowflake = new Snowflake(ThreadLocalRandom.current().nextInt(1, 30), ThreadLocalRandom.current().nextInt(1, 30));
    }

    public WsUuid(long workerId, long dataCenterId) {
        snowflake = new Snowflake(workerId, dataCenterId);
    }

    /**
     * @return
     * @author wchao
     */
    public String uuid() {
        return snowflake.nextId() + "";
    }

}
